{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "46fa56f3",
   "metadata": {},
   "source": [
    "## Pandas\n",
    "### Series\n",
    "1. 一列\n",
    "2. 有索引的一维数组\n",
    "index value\n",
    " a    0.2\n",
    " b    0.5\n",
    " c    0.75\n",
    " d    1.0\n",
    "### DataFrame\n",
    "index  name   sex\n",
    "a    yi    male\n",
    "b    kk    female\n",
    "c    mm    male"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 75,
   "id": "243bfe08",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 引入numpy 和pandas 库\n",
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "c790c838",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a    0.20\n",
      "b    0.50\n",
      "c    0.75\n",
      "d    1.00\n",
      "dtype: float64\n"
     ]
    }
   ],
   "source": [
    "s = pd.Series([0.2,0.5,0.75,1.0],index=['a','b','c','d'])\n",
    "print(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "a5bb497c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "True\n"
     ]
    }
   ],
   "source": [
    "# 可以使用python中的字典方法来查看索引和值\n",
    "print('a' in s) #查看某值是否是索引\n",
    "print(0.2 in s.values) #查看某值是否是值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "id": "8aae533f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Index(['a', 'b', 'c', 'd'], dtype='object')\n"
     ]
    }
   ],
   "source": [
    "print(s.keys()) #查看索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "e6e5cc5b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.2  0.5  0.75 1.  ]\n"
     ]
    }
   ],
   "source": [
    "print(s.values) #查看值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "id": "065fd6aa",
   "metadata": {},
   "outputs": [],
   "source": [
    "#data = pd.read_csv('testCsvFile.csv',header=0,index_col=0,encoding='gb2312')#最基本的引入方式，中文编码:gb2312,utf-8\n",
    "# header参数传入None,或者数字，数字代表第多少行作为标题栏（下标从0开始）\n",
    "# index_col参数传入None，或者数字，数字代表第多少列作为索引栏（下标从0开始）\n",
    "#data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "11629a64",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 拿取江苏这一行的内容\n",
    "# iloc索引器\n",
    "# 数据源.iloc[行开始下标:行结束下标,列开始下标:列结束下标]\n",
    "#data.iloc[1:3,1:] # 表格从开始到第三行，第一列的内容"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 82,
   "id": "aff4f411",
   "metadata": {},
   "outputs": [],
   "source": [
    "#loc索引器\n",
    "# data.loc['上海':'浙江','编号':'是否']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "id": "25b55b41",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 取单个列\n",
    "#data['编号']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "id": "bd8b8ea1",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 看整个数据的前5行\n",
    "#data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "056231e1",
   "metadata": {},
   "source": [
    "data.head()或者tail()用来查看数据头部和尾部，其中可以传入参数n代表看多少行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "id": "59d01105",
   "metadata": {},
   "outputs": [],
   "source": [
    "#看整个数据的后5行\n",
    "#data.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "id": "601e9315",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2021年</th>\n",
       "      <th>2020年</th>\n",
       "      <th>2019年</th>\n",
       "      <th>2018年</th>\n",
       "      <th>2017年</th>\n",
       "      <th>2016年</th>\n",
       "      <th>2015年</th>\n",
       "      <th>2014年</th>\n",
       "      <th>2013年</th>\n",
       "      <th>2012年</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>指标</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>居民人均消费支出(元)</th>\n",
       "      <td>24100.0</td>\n",
       "      <td>21210.0</td>\n",
       "      <td>21559.0</td>\n",
       "      <td>19853.0</td>\n",
       "      <td>18322.0</td>\n",
       "      <td>17111.0</td>\n",
       "      <td>15712.0</td>\n",
       "      <td>14491.0</td>\n",
       "      <td>13220.0</td>\n",
       "      <td>12054.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均消费支出比上年增长(%)</th>\n",
       "      <td>12.6</td>\n",
       "      <td>-4.0</td>\n",
       "      <td>5.5</td>\n",
       "      <td>6.2</td>\n",
       "      <td>5.4</td>\n",
       "      <td>6.8</td>\n",
       "      <td>6.9</td>\n",
       "      <td>7.5</td>\n",
       "      <td>6.9</td>\n",
       "      <td>8.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均服务性消费支出(元)</th>\n",
       "      <td>10645.0</td>\n",
       "      <td>9037.0</td>\n",
       "      <td>9886.0</td>\n",
       "      <td>8781.0</td>\n",
       "      <td>7803.0</td>\n",
       "      <td>7157.0</td>\n",
       "      <td>6460.0</td>\n",
       "      <td>5842.0</td>\n",
       "      <td>5246.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均服务性消费支出比上年增长(%)</th>\n",
       "      <td>17.8</td>\n",
       "      <td>-8.6</td>\n",
       "      <td>12.6</td>\n",
       "      <td>12.5</td>\n",
       "      <td>9.0</td>\n",
       "      <td>10.8</td>\n",
       "      <td>10.6</td>\n",
       "      <td>11.4</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均食品烟酒支出(元)</th>\n",
       "      <td>7178.0</td>\n",
       "      <td>6397.0</td>\n",
       "      <td>6084.0</td>\n",
       "      <td>5631.0</td>\n",
       "      <td>5374.0</td>\n",
       "      <td>5151.0</td>\n",
       "      <td>4814.0</td>\n",
       "      <td>4494.0</td>\n",
       "      <td>4127.0</td>\n",
       "      <td>3983.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均食品烟酒支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>5.1</td>\n",
       "      <td>8.0</td>\n",
       "      <td>4.8</td>\n",
       "      <td>4.3</td>\n",
       "      <td>7.0</td>\n",
       "      <td>7.1</td>\n",
       "      <td>8.9</td>\n",
       "      <td>3.6</td>\n",
       "      <td>9.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均衣着支出(元)</th>\n",
       "      <td>1419.0</td>\n",
       "      <td>1238.0</td>\n",
       "      <td>1338.0</td>\n",
       "      <td>1289.0</td>\n",
       "      <td>1238.0</td>\n",
       "      <td>1203.0</td>\n",
       "      <td>1164.0</td>\n",
       "      <td>1099.0</td>\n",
       "      <td>1027.0</td>\n",
       "      <td>992.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均衣着支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>-7.5</td>\n",
       "      <td>3.8</td>\n",
       "      <td>4.1</td>\n",
       "      <td>2.9</td>\n",
       "      <td>3.3</td>\n",
       "      <td>5.9</td>\n",
       "      <td>7.0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>9.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均居住支出(元)</th>\n",
       "      <td>5641.0</td>\n",
       "      <td>5215.0</td>\n",
       "      <td>5055.0</td>\n",
       "      <td>4647.0</td>\n",
       "      <td>4107.0</td>\n",
       "      <td>3746.0</td>\n",
       "      <td>3419.0</td>\n",
       "      <td>3201.0</td>\n",
       "      <td>2999.0</td>\n",
       "      <td>2480.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均居住支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>3.2</td>\n",
       "      <td>8.8</td>\n",
       "      <td>13.1</td>\n",
       "      <td>9.6</td>\n",
       "      <td>9.6</td>\n",
       "      <td>6.8</td>\n",
       "      <td>6.7</td>\n",
       "      <td>20.9</td>\n",
       "      <td>12.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均生活用品及服务支出(元)</th>\n",
       "      <td>1423.0</td>\n",
       "      <td>1260.0</td>\n",
       "      <td>1281.0</td>\n",
       "      <td>1223.0</td>\n",
       "      <td>1121.0</td>\n",
       "      <td>1044.0</td>\n",
       "      <td>951.0</td>\n",
       "      <td>890.0</td>\n",
       "      <td>806.0</td>\n",
       "      <td>741.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均生活用品及服务支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>-1.7</td>\n",
       "      <td>4.8</td>\n",
       "      <td>9.1</td>\n",
       "      <td>7.4</td>\n",
       "      <td>9.7</td>\n",
       "      <td>6.9</td>\n",
       "      <td>10.3</td>\n",
       "      <td>8.8</td>\n",
       "      <td>9.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均交通通信支出(元)</th>\n",
       "      <td>3156.0</td>\n",
       "      <td>2762.0</td>\n",
       "      <td>2862.0</td>\n",
       "      <td>2675.0</td>\n",
       "      <td>2499.0</td>\n",
       "      <td>2338.0</td>\n",
       "      <td>2087.0</td>\n",
       "      <td>1869.0</td>\n",
       "      <td>1627.0</td>\n",
       "      <td>1451.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均交通通信支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>-3.5</td>\n",
       "      <td>7.0</td>\n",
       "      <td>7.1</td>\n",
       "      <td>6.9</td>\n",
       "      <td>12.0</td>\n",
       "      <td>11.6</td>\n",
       "      <td>14.9</td>\n",
       "      <td>12.2</td>\n",
       "      <td>15.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均教育文化娱乐支出(元)</th>\n",
       "      <td>2599.0</td>\n",
       "      <td>2032.0</td>\n",
       "      <td>2513.0</td>\n",
       "      <td>2226.0</td>\n",
       "      <td>2086.0</td>\n",
       "      <td>1915.0</td>\n",
       "      <td>1723.0</td>\n",
       "      <td>1536.0</td>\n",
       "      <td>1398.0</td>\n",
       "      <td>1262.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均教育文化娱乐支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>-19.1</td>\n",
       "      <td>12.9</td>\n",
       "      <td>6.7</td>\n",
       "      <td>8.9</td>\n",
       "      <td>11.2</td>\n",
       "      <td>12.2</td>\n",
       "      <td>9.9</td>\n",
       "      <td>10.8</td>\n",
       "      <td>11.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均医疗保健支出(元)</th>\n",
       "      <td>2115.0</td>\n",
       "      <td>1843.0</td>\n",
       "      <td>1902.0</td>\n",
       "      <td>1685.0</td>\n",
       "      <td>1451.0</td>\n",
       "      <td>1307.0</td>\n",
       "      <td>1165.0</td>\n",
       "      <td>1045.0</td>\n",
       "      <td>912.0</td>\n",
       "      <td>838.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均医疗保健支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>-3.1</td>\n",
       "      <td>12.9</td>\n",
       "      <td>16.1</td>\n",
       "      <td>11.0</td>\n",
       "      <td>12.3</td>\n",
       "      <td>11.5</td>\n",
       "      <td>14.5</td>\n",
       "      <td>8.8</td>\n",
       "      <td>12.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均其他用品及服务支出(元)</th>\n",
       "      <td>569.0</td>\n",
       "      <td>462.0</td>\n",
       "      <td>524.0</td>\n",
       "      <td>477.0</td>\n",
       "      <td>447.0</td>\n",
       "      <td>406.0</td>\n",
       "      <td>389.0</td>\n",
       "      <td>358.0</td>\n",
       "      <td>325.0</td>\n",
       "      <td>307.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均其他用品及服务支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>-11.8</td>\n",
       "      <td>9.7</td>\n",
       "      <td>6.8</td>\n",
       "      <td>10.0</td>\n",
       "      <td>4.4</td>\n",
       "      <td>8.7</td>\n",
       "      <td>10.3</td>\n",
       "      <td>5.6</td>\n",
       "      <td>12.9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                         2021年    2020年    2019年    2018年    2017年    2016年  \\\n",
       "指标                                                                            \n",
       "居民人均消费支出(元)            24100.0  21210.0  21559.0  19853.0  18322.0  17111.0   \n",
       "居民人均消费支出比上年增长(%)          12.6     -4.0      5.5      6.2      5.4      6.8   \n",
       "居民人均服务性消费支出(元)         10645.0   9037.0   9886.0   8781.0   7803.0   7157.0   \n",
       "居民人均服务性消费支出比上年增长(%)       17.8     -8.6     12.6     12.5      9.0     10.8   \n",
       "居民人均食品烟酒支出(元)           7178.0   6397.0   6084.0   5631.0   5374.0   5151.0   \n",
       "居民人均食品烟酒支出比上年增长(%)         NaN      5.1      8.0      4.8      4.3      7.0   \n",
       "居民人均衣着支出(元)             1419.0   1238.0   1338.0   1289.0   1238.0   1203.0   \n",
       "居民人均衣着支出比上年增长(%)           NaN     -7.5      3.8      4.1      2.9      3.3   \n",
       "居民人均居住支出(元)             5641.0   5215.0   5055.0   4647.0   4107.0   3746.0   \n",
       "居民人均居住支出比上年增长(%)           NaN      3.2      8.8     13.1      9.6      9.6   \n",
       "居民人均生活用品及服务支出(元)        1423.0   1260.0   1281.0   1223.0   1121.0   1044.0   \n",
       "居民人均生活用品及服务支出比上年增长(%)      NaN     -1.7      4.8      9.1      7.4      9.7   \n",
       "居民人均交通通信支出(元)           3156.0   2762.0   2862.0   2675.0   2499.0   2338.0   \n",
       "居民人均交通通信支出比上年增长(%)         NaN     -3.5      7.0      7.1      6.9     12.0   \n",
       "居民人均教育文化娱乐支出(元)         2599.0   2032.0   2513.0   2226.0   2086.0   1915.0   \n",
       "居民人均教育文化娱乐支出比上年增长(%)       NaN    -19.1     12.9      6.7      8.9     11.2   \n",
       "居民人均医疗保健支出(元)           2115.0   1843.0   1902.0   1685.0   1451.0   1307.0   \n",
       "居民人均医疗保健支出比上年增长(%)         NaN     -3.1     12.9     16.1     11.0     12.3   \n",
       "居民人均其他用品及服务支出(元)         569.0    462.0    524.0    477.0    447.0    406.0   \n",
       "居民人均其他用品及服务支出比上年增长(%)      NaN    -11.8      9.7      6.8     10.0      4.4   \n",
       "\n",
       "                         2015年    2014年    2013年    2012年  \n",
       "指标                                                         \n",
       "居民人均消费支出(元)            15712.0  14491.0  13220.0  12054.0  \n",
       "居民人均消费支出比上年增长(%)           6.9      7.5      6.9      8.6  \n",
       "居民人均服务性消费支出(元)          6460.0   5842.0   5246.0      NaN  \n",
       "居民人均服务性消费支出比上年增长(%)       10.6     11.4      NaN      NaN  \n",
       "居民人均食品烟酒支出(元)           4814.0   4494.0   4127.0   3983.0  \n",
       "居民人均食品烟酒支出比上年增长(%)         7.1      8.9      3.6      9.6  \n",
       "居民人均衣着支出(元)             1164.0   1099.0   1027.0    992.0  \n",
       "居民人均衣着支出比上年增长(%)           5.9      7.0      3.6      9.9  \n",
       "居民人均居住支出(元)             3419.0   3201.0   2999.0   2480.0  \n",
       "居民人均居住支出比上年增长(%)           6.8      6.7     20.9     12.8  \n",
       "居民人均生活用品及服务支出(元)         951.0    890.0    806.0    741.0  \n",
       "居民人均生活用品及服务支出比上年增长(%)      6.9     10.3      8.8      9.8  \n",
       "居民人均交通通信支出(元)           2087.0   1869.0   1627.0   1451.0  \n",
       "居民人均交通通信支出比上年增长(%)        11.6     14.9     12.2     15.3  \n",
       "居民人均教育文化娱乐支出(元)         1723.0   1536.0   1398.0   1262.0  \n",
       "居民人均教育文化娱乐支出比上年增长(%)      12.2      9.9     10.8     11.1  \n",
       "居民人均医疗保健支出(元)           1165.0   1045.0    912.0    838.0  \n",
       "居民人均医疗保健支出比上年增长(%)        11.5     14.5      8.8     12.7  \n",
       "居民人均其他用品及服务支出(元)         389.0    358.0    325.0    307.0  \n",
       "居民人均其他用品及服务支出比上年增长(%)      8.7     10.3      5.6     12.9  "
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data = pd.read_csv('年度数据.csv',index_col=0,encoding='gb2312')\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "id": "b1dc719d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2021年</th>\n",
       "      <th>2012年</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>指标</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>居民人均消费支出(元)</th>\n",
       "      <td>24100.0</td>\n",
       "      <td>12054.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均消费支出比上年增长(%)</th>\n",
       "      <td>12.6</td>\n",
       "      <td>8.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均服务性消费支出(元)</th>\n",
       "      <td>10645.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均服务性消费支出比上年增长(%)</th>\n",
       "      <td>17.8</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均食品烟酒支出(元)</th>\n",
       "      <td>7178.0</td>\n",
       "      <td>3983.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均食品烟酒支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>9.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均衣着支出(元)</th>\n",
       "      <td>1419.0</td>\n",
       "      <td>992.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均衣着支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>9.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均居住支出(元)</th>\n",
       "      <td>5641.0</td>\n",
       "      <td>2480.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均居住支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>12.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均生活用品及服务支出(元)</th>\n",
       "      <td>1423.0</td>\n",
       "      <td>741.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均生活用品及服务支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>9.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均交通通信支出(元)</th>\n",
       "      <td>3156.0</td>\n",
       "      <td>1451.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均交通通信支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>15.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均教育文化娱乐支出(元)</th>\n",
       "      <td>2599.0</td>\n",
       "      <td>1262.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均教育文化娱乐支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>11.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均医疗保健支出(元)</th>\n",
       "      <td>2115.0</td>\n",
       "      <td>838.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均医疗保健支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>12.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均其他用品及服务支出(元)</th>\n",
       "      <td>569.0</td>\n",
       "      <td>307.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>居民人均其他用品及服务支出比上年增长(%)</th>\n",
       "      <td>NaN</td>\n",
       "      <td>12.9</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                         2021年    2012年\n",
       "指标                                     \n",
       "居民人均消费支出(元)            24100.0  12054.0\n",
       "居民人均消费支出比上年增长(%)          12.6      8.6\n",
       "居民人均服务性消费支出(元)         10645.0      NaN\n",
       "居民人均服务性消费支出比上年增长(%)       17.8      NaN\n",
       "居民人均食品烟酒支出(元)           7178.0   3983.0\n",
       "居民人均食品烟酒支出比上年增长(%)         NaN      9.6\n",
       "居民人均衣着支出(元)             1419.0    992.0\n",
       "居民人均衣着支出比上年增长(%)           NaN      9.9\n",
       "居民人均居住支出(元)             5641.0   2480.0\n",
       "居民人均居住支出比上年增长(%)           NaN     12.8\n",
       "居民人均生活用品及服务支出(元)        1423.0    741.0\n",
       "居民人均生活用品及服务支出比上年增长(%)      NaN      9.8\n",
       "居民人均交通通信支出(元)           3156.0   1451.0\n",
       "居民人均交通通信支出比上年增长(%)         NaN     15.3\n",
       "居民人均教育文化娱乐支出(元)         2599.0   1262.0\n",
       "居民人均教育文化娱乐支出比上年增长(%)       NaN     11.1\n",
       "居民人均医疗保健支出(元)           2115.0    838.0\n",
       "居民人均医疗保健支出比上年增长(%)         NaN     12.7\n",
       "居民人均其他用品及服务支出(元)         569.0    307.0\n",
       "居民人均其他用品及服务支出比上年增长(%)      NaN     12.9"
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 中国国家统计，csv\n",
    "# 显示表\n",
    "# 通过Head,tail查看一下头部尾部看一下概览\n",
    "# 分别通过iloc 和loc去获取感兴趣的部分内容\n",
    "# 取单个/多个列看内容\n",
    "data[['2021年','2012年']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6996701d",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
